import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/pay/create_order_entity.dart';

Discount $DiscountFromJson(Map<String, dynamic> json) {
  final Discount discount = Discount();
  final String? discountAmount = jsonConvert.convert<String>(json['discountAmount']);
  if (discountAmount != null) {
    discount.discountAmount = discountAmount;
  }
  final String? discountDesc = jsonConvert.convert<String>(json['discountDesc']);
  if (discountDesc != null) {
    discount.discountDesc = discountDesc;
  }
  final String? discountTypeName = jsonConvert.convert<String>(json['discountTypeName']);
  if (discountTypeName != null) {
    discount.discountTypeName = discountTypeName;
  }
  final String? discountType = jsonConvert.convert<String>(json['discountType']);
  if (discountType != null) {
    discount.discountType = discountType;
  }
  final String? exclusiveStatus = jsonConvert.convert<String>(json['exclusiveStatus']);
  if (exclusiveStatus != null) {
    discount.exclusiveStatus = exclusiveStatus;
  }
  final String? promotionsDetailId = jsonConvert.convert<String>(json['promotionsDetailId']);
  if (promotionsDetailId != null) {
    discount.promotionsDetailId = promotionsDetailId;
  }
  final String? promotionsId = jsonConvert.convert<String>(json['promotionsId']);
  if (promotionsId != null) {
    discount.promotionsId = promotionsId;
  }
  final String? memberCouponId = jsonConvert.convert<String>(json['memberCouponId']);
  if (memberCouponId != null) {
    discount.memberCouponId = memberCouponId;
  }
  final String? discountBizId = jsonConvert.convert<String>(json['discountBizId']);
  if (discountBizId != null) {
    discount.discountBizId = discountBizId;
  }
  final int? customDataType = jsonConvert.convert<int>(json['customDataType']);
  if (customDataType != null) {
    discount.customDataType = customDataType;
  }
  final List<GoodsDetail>? goodsDetails = (json['goodsDetails'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<GoodsDetail>(e) as GoodsDetail).toList();
  if (goodsDetails != null) {
    discount.goodsDetails = goodsDetails;
  }
  final String? useIntegral = jsonConvert.convert<String>(json['useIntegral']);
  if (useIntegral != null) {
    discount.useIntegral = useIntegral;
  }
  return discount;
}

Map<String, dynamic> $DiscountToJson(Discount entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['discountAmount'] = entity.discountAmount;
  data['discountDesc'] = entity.discountDesc;
  data['discountTypeName'] = entity.discountTypeName;
  data['discountType'] = entity.discountType;
  data['exclusiveStatus'] = entity.exclusiveStatus;
  data['promotionsDetailId'] = entity.promotionsDetailId;
  data['promotionsId'] = entity.promotionsId;
  data['memberCouponId'] = entity.memberCouponId;
  data['discountBizId'] = entity.discountBizId;
  data['customDataType'] = entity.customDataType;
  data['goodsDetails'] = entity.goodsDetails.map((v) => v.toJson()).toList();
  data['useIntegral'] = entity.useIntegral;
  return data;
}

extension DiscountExtension on Discount {
  Discount copyWith({
    String? discountAmount,
    String? discountDesc,
    String? discountTypeName,
    String? discountType,
    String? exclusiveStatus,
    String? promotionsDetailId,
    String? promotionsId,
    String? memberCouponId,
    String? discountBizId,
    int? customDataType,
    List<GoodsDetail>? goodsDetails,
    String? useIntegral,
  }) {
    return Discount()
      ..discountAmount = discountAmount ?? this.discountAmount
      ..discountDesc = discountDesc ?? this.discountDesc
      ..discountTypeName = discountTypeName ?? this.discountTypeName
      ..discountType = discountType ?? this.discountType
      ..exclusiveStatus = exclusiveStatus ?? this.exclusiveStatus
      ..promotionsDetailId = promotionsDetailId ?? this.promotionsDetailId
      ..promotionsId = promotionsId ?? this.promotionsId
      ..memberCouponId = memberCouponId ?? this.memberCouponId
      ..discountBizId = discountBizId ?? this.discountBizId
      ..customDataType = customDataType ?? this.customDataType
      ..goodsDetails = goodsDetails ?? this.goodsDetails
      ..useIntegral = useIntegral ?? this.useIntegral;
  }
}

GoodsDetail $GoodsDetailFromJson(Map<String, dynamic> json) {
  final GoodsDetail goodsDetail = GoodsDetail();
  final String? discountAmount = jsonConvert.convert<String>(json['discountAmount']);
  if (discountAmount != null) {
    goodsDetail.discountAmount = discountAmount;
  }
  final String? goodsId = jsonConvert.convert<String>(json['goodsId']);
  if (goodsId != null) {
    goodsDetail.goodsId = goodsId;
  }
  final String? discountQuantity = jsonConvert.convert<String>(json['discountQuantity']);
  if (discountQuantity != null) {
    goodsDetail.discountQuantity = discountQuantity;
  }
  final String? salesChannelGoodsId = jsonConvert.convert<String>(json['salesChannelGoodsId']);
  if (salesChannelGoodsId != null) {
    goodsDetail.salesChannelGoodsId = salesChannelGoodsId;
  }
  final String? useIntegral = jsonConvert.convert<String>(json['useIntegral']);
  if (useIntegral != null) {
    goodsDetail.useIntegral = useIntegral;
  }
  return goodsDetail;
}

Map<String, dynamic> $GoodsDetailToJson(GoodsDetail entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['discountAmount'] = entity.discountAmount;
  data['goodsId'] = entity.goodsId;
  data['discountQuantity'] = entity.discountQuantity;
  data['salesChannelGoodsId'] = entity.salesChannelGoodsId;
  data['useIntegral'] = entity.useIntegral;
  return data;
}

extension GoodsDetailExtension on GoodsDetail {
  GoodsDetail copyWith({
    String? discountAmount,
    String? goodsId,
    String? discountQuantity,
    String? salesChannelGoodsId,
    String? useIntegral,
  }) {
    return GoodsDetail()
      ..discountAmount = discountAmount ?? this.discountAmount
      ..goodsId = goodsId ?? this.goodsId
      ..discountQuantity = discountQuantity ?? this.discountQuantity
      ..salesChannelGoodsId = salesChannelGoodsId ?? this.salesChannelGoodsId
      ..useIntegral = useIntegral ?? this.useIntegral;
  }
}

EnergyGoods $EnergyGoodsFromJson(Map<String, dynamic> json) {
  final EnergyGoods energyGoods = EnergyGoods();
  final String? goodsAmount = jsonConvert.convert<String>(json['goodsAmount']);
  if (goodsAmount != null) {
    energyGoods.goodsAmount = goodsAmount;
  }
  final String? mchGoodsId = jsonConvert.convert<String>(json['mchGoodsId']);
  if (mchGoodsId != null) {
    energyGoods.mchGoodsId = mchGoodsId;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    energyGoods.price = price;
  }
  final String? quantity = jsonConvert.convert<String>(json['quantity']);
  if (quantity != null) {
    energyGoods.quantity = quantity;
  }
  final String? shelfId = jsonConvert.convert<String>(json['shelfId']);
  if (shelfId != null) {
    energyGoods.shelfId = shelfId;
  }
  final String? shelfNo = jsonConvert.convert<String>(json['shelfNo']);
  if (shelfNo != null) {
    energyGoods.shelfNo = shelfNo;
  }
  return energyGoods;
}

Map<String, dynamic> $EnergyGoodsToJson(EnergyGoods entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['goodsAmount'] = entity.goodsAmount;
  data['mchGoodsId'] = entity.mchGoodsId;
  data['price'] = entity.price;
  data['quantity'] = entity.quantity;
  data['shelfId'] = entity.shelfId;
  data['shelfNo'] = entity.shelfNo;
  return data;
}

extension EnergyGoodsExtension on EnergyGoods {
  EnergyGoods copyWith({
    String? goodsAmount,
    String? mchGoodsId,
    String? price,
    String? quantity,
    String? shelfId,
    String? shelfNo,
  }) {
    return EnergyGoods()
      ..goodsAmount = goodsAmount ?? this.goodsAmount
      ..mchGoodsId = mchGoodsId ?? this.mchGoodsId
      ..price = price ?? this.price
      ..quantity = quantity ?? this.quantity
      ..shelfId = shelfId ?? this.shelfId
      ..shelfNo = shelfNo ?? this.shelfNo;
  }
}

CreateOrderOfflineDiscounts $CreateOrderOfflineDiscountsFromJson(Map<String, dynamic> json) {
  final CreateOrderOfflineDiscounts createOrderOfflineDiscounts = CreateOrderOfflineDiscounts();
  final String? offlineDiscountsAmount = jsonConvert.convert<String>(json['offlineDiscountsAmount']);
  if (offlineDiscountsAmount != null) {
    createOrderOfflineDiscounts.offlineDiscountsAmount = offlineDiscountsAmount;
  }
  final int? promotionsMode = jsonConvert.convert<int>(json['promotionsMode']);
  if (promotionsMode != null) {
    createOrderOfflineDiscounts.promotionsMode = promotionsMode;
  }
  final String? orderPromotionsActivityId = jsonConvert.convert<String>(json['orderPromotionsActivityId']);
  if (orderPromotionsActivityId != null) {
    createOrderOfflineDiscounts.orderPromotionsActivityId = orderPromotionsActivityId;
  }
  final String? strength = jsonConvert.convert<String>(json['strength']);
  if (strength != null) {
    createOrderOfflineDiscounts.strength = strength;
  }
  return createOrderOfflineDiscounts;
}

Map<String, dynamic> $CreateOrderOfflineDiscountsToJson(CreateOrderOfflineDiscounts entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['offlineDiscountsAmount'] = entity.offlineDiscountsAmount;
  data['promotionsMode'] = entity.promotionsMode;
  data['orderPromotionsActivityId'] = entity.orderPromotionsActivityId;
  data['strength'] = entity.strength;
  return data;
}

extension CreateOrderOfflineDiscountsExtension on CreateOrderOfflineDiscounts {
  CreateOrderOfflineDiscounts copyWith({
    String? offlineDiscountsAmount,
    int? promotionsMode,
    String? orderPromotionsActivityId,
    String? strength,
  }) {
    return CreateOrderOfflineDiscounts()
      ..offlineDiscountsAmount = offlineDiscountsAmount ?? this.offlineDiscountsAmount
      ..promotionsMode = promotionsMode ?? this.promotionsMode
      ..orderPromotionsActivityId = orderPromotionsActivityId ?? this.orderPromotionsActivityId
      ..strength = strength ?? this.strength;
  }
}

PayInfo $PayInfoFromJson(Map<String, dynamic> json) {
  final PayInfo payInfo = PayInfo();
  final String? accountType = jsonConvert.convert<String>(json['accountType']);
  if (accountType != null) {
    payInfo.accountType = accountType;
  }
  final String? authCode = jsonConvert.convert<String>(json['authCode']);
  if (authCode != null) {
    payInfo.authCode = authCode;
  }
  final String? consumeIntegral = jsonConvert.convert<String>(json['consumeIntegral']);
  if (consumeIntegral != null) {
    payInfo.consumeIntegral = consumeIntegral;
  }
  final String? memberAccountId = jsonConvert.convert<String>(json['memberAccountId']);
  if (memberAccountId != null) {
    payInfo.memberAccountId = memberAccountId;
  }
  final String? orderFinanceId = jsonConvert.convert<String>(json['orderFinanceId']);
  if (orderFinanceId != null) {
    payInfo.orderFinanceId = orderFinanceId;
  }
  final String? password = jsonConvert.convert<String>(json['password']);
  if (password != null) {
    payInfo.password = password;
  }
  final String? payAmount = jsonConvert.convert<String>(json['payAmount']);
  if (payAmount != null) {
    payInfo.payAmount = payAmount;
  }
  final String? payMethod = jsonConvert.convert<String>(json['payMethod']);
  if (payMethod != null) {
    payInfo.payMethod = payMethod;
  }
  final String? payOrderId = jsonConvert.convert<String>(json['payOrderId']);
  if (payOrderId != null) {
    payInfo.payOrderId = payOrderId;
  }
  final String? payType = jsonConvert.convert<String>(json['payType']);
  if (payType != null) {
    payInfo.payType = payType;
  }
  final List<PayDouYCoupon>? thirdDouYCouponRequests = (json['thirdDouYCouponRequests'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PayDouYCoupon>(e) as PayDouYCoupon).toList();
  if (thirdDouYCouponRequests != null) {
    payInfo.thirdDouYCouponRequests = thirdDouYCouponRequests;
  }
  return payInfo;
}

Map<String, dynamic> $PayInfoToJson(PayInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['accountType'] = entity.accountType;
  data['authCode'] = entity.authCode;
  data['consumeIntegral'] = entity.consumeIntegral;
  data['memberAccountId'] = entity.memberAccountId;
  data['orderFinanceId'] = entity.orderFinanceId;
  data['password'] = entity.password;
  data['payAmount'] = entity.payAmount;
  data['payMethod'] = entity.payMethod;
  data['payOrderId'] = entity.payOrderId;
  data['payType'] = entity.payType;
  data['thirdDouYCouponRequests'] = entity.thirdDouYCouponRequests?.map((v) => v.toJson()).toList();
  return data;
}

extension PayInfoExtension on PayInfo {
  PayInfo copyWith({
    String? accountType,
    String? authCode,
    String? consumeIntegral,
    String? memberAccountId,
    String? orderFinanceId,
    String? password,
    String? payAmount,
    String? payMethod,
    String? payOrderId,
    String? payType,
    List<PayDouYCoupon>? thirdDouYCouponRequests,
  }) {
    return PayInfo()
      ..accountType = accountType ?? this.accountType
      ..authCode = authCode ?? this.authCode
      ..consumeIntegral = consumeIntegral ?? this.consumeIntegral
      ..memberAccountId = memberAccountId ?? this.memberAccountId
      ..orderFinanceId = orderFinanceId ?? this.orderFinanceId
      ..password = password ?? this.password
      ..payAmount = payAmount ?? this.payAmount
      ..payMethod = payMethod ?? this.payMethod
      ..payOrderId = payOrderId ?? this.payOrderId
      ..payType = payType ?? this.payType
      ..thirdDouYCouponRequests = thirdDouYCouponRequests ?? this.thirdDouYCouponRequests;
  }
}

PayDouYCoupon $PayDouYCouponFromJson(Map<String, dynamic> json) {
  final PayDouYCoupon payDouYCoupon = PayDouYCoupon();
  final String? beginTime = jsonConvert.convert<String>(json['beginTime']);
  if (beginTime != null) {
    payDouYCoupon.beginTime = beginTime;
  }
  final String? certificateId = jsonConvert.convert<String>(json['certificateId']);
  if (certificateId != null) {
    payDouYCoupon.certificateId = certificateId;
  }
  final String? encryptedCode = jsonConvert.convert<String>(json['encryptedCode']);
  if (encryptedCode != null) {
    payDouYCoupon.encryptedCode = encryptedCode;
  }
  final String? endTime = jsonConvert.convert<String>(json['endTime']);
  if (endTime != null) {
    payDouYCoupon.endTime = endTime;
  }
  final int? listMarketAmount = jsonConvert.convert<int>(json['listMarketAmount']);
  if (listMarketAmount != null) {
    payDouYCoupon.listMarketAmount = listMarketAmount;
  }
  final int? originalAmount = jsonConvert.convert<int>(json['originalAmount']);
  if (originalAmount != null) {
    payDouYCoupon.originalAmount = originalAmount;
  }
  final String? skuId = jsonConvert.convert<String>(json['skuId']);
  if (skuId != null) {
    payDouYCoupon.skuId = skuId;
  }
  final String? storeId = jsonConvert.convert<String>(json['storeId']);
  if (storeId != null) {
    payDouYCoupon.storeId = storeId;
  }
  final String? tikTokeOrderId = jsonConvert.convert<String>(json['tikTokeOrderId']);
  if (tikTokeOrderId != null) {
    payDouYCoupon.tikTokeOrderId = tikTokeOrderId;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    payDouYCoupon.title = title;
  }
  final String? verifyToken = jsonConvert.convert<String>(json['verifyToken']);
  if (verifyToken != null) {
    payDouYCoupon.verifyToken = verifyToken;
  }
  return payDouYCoupon;
}

Map<String, dynamic> $PayDouYCouponToJson(PayDouYCoupon entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['beginTime'] = entity.beginTime;
  data['certificateId'] = entity.certificateId;
  data['encryptedCode'] = entity.encryptedCode;
  data['endTime'] = entity.endTime;
  data['listMarketAmount'] = entity.listMarketAmount;
  data['originalAmount'] = entity.originalAmount;
  data['skuId'] = entity.skuId;
  data['storeId'] = entity.storeId;
  data['tikTokeOrderId'] = entity.tikTokeOrderId;
  data['title'] = entity.title;
  data['verifyToken'] = entity.verifyToken;
  return data;
}

extension PayDouYCouponExtension on PayDouYCoupon {
  PayDouYCoupon copyWith({
    String? beginTime,
    String? certificateId,
    String? encryptedCode,
    String? endTime,
    int? listMarketAmount,
    int? originalAmount,
    String? skuId,
    String? storeId,
    String? tikTokeOrderId,
    String? title,
    String? verifyToken,
  }) {
    return PayDouYCoupon()
      ..beginTime = beginTime ?? this.beginTime
      ..certificateId = certificateId ?? this.certificateId
      ..encryptedCode = encryptedCode ?? this.encryptedCode
      ..endTime = endTime ?? this.endTime
      ..listMarketAmount = listMarketAmount ?? this.listMarketAmount
      ..originalAmount = originalAmount ?? this.originalAmount
      ..skuId = skuId ?? this.skuId
      ..storeId = storeId ?? this.storeId
      ..tikTokeOrderId = tikTokeOrderId ?? this.tikTokeOrderId
      ..title = title ?? this.title
      ..verifyToken = verifyToken ?? this.verifyToken;
  }
}

StoreGoodsInfos $StoreGoodsInfosFromJson(Map<String, dynamic> json) {
  final StoreGoodsInfos storeGoodsInfos = StoreGoodsInfos();
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    storeGoodsInfos.price = price;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    storeGoodsInfos.quantity = quantity;
  }
  final String? mchGoodsId = jsonConvert.convert<String>(json['mchGoodsId']);
  if (mchGoodsId != null) {
    storeGoodsInfos.mchGoodsId = mchGoodsId;
  }
  final String? goodsAmount = jsonConvert.convert<String>(json['goodsAmount']);
  if (goodsAmount != null) {
    storeGoodsInfos.goodsAmount = goodsAmount;
  }
  final String? salesChannelGoodsId = jsonConvert.convert<String>(json['salesChannelGoodsId']);
  if (salesChannelGoodsId != null) {
    storeGoodsInfos.salesChannelGoodsId = salesChannelGoodsId;
  }
  return storeGoodsInfos;
}

Map<String, dynamic> $StoreGoodsInfosToJson(StoreGoodsInfos entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['price'] = entity.price;
  data['quantity'] = entity.quantity;
  data['mchGoodsId'] = entity.mchGoodsId;
  data['goodsAmount'] = entity.goodsAmount;
  data['salesChannelGoodsId'] = entity.salesChannelGoodsId;
  return data;
}

extension StoreGoodsInfosExtension on StoreGoodsInfos {
  StoreGoodsInfos copyWith({
    String? price,
    int? quantity,
    String? mchGoodsId,
    String? goodsAmount,
    String? salesChannelGoodsId,
  }) {
    return StoreGoodsInfos()
      ..price = price ?? this.price
      ..quantity = quantity ?? this.quantity
      ..mchGoodsId = mchGoodsId ?? this.mchGoodsId
      ..goodsAmount = goodsAmount ?? this.goodsAmount
      ..salesChannelGoodsId = salesChannelGoodsId ?? this.salesChannelGoodsId;
  }
}